package www.reagnetbox.com.adapter;

import android.content.Context;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import www.reagnetbox.com.R;
import www.reagnetbox.com.bean.User;
import www.reagnetbox.com.others.Const;

public class UserListAdapter extends BaseQuickAdapter<User, BaseViewHolder> {
    private BaseViewHolder viewHolder;
    private Context context;

    public UserListAdapter(Context context, int resContentView, List<User> data) {
        super(resContentView, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder viewHolder, User item) {
        this.viewHolder = viewHolder;
        viewHolder
                .setText(R.id.tv_username, item.getUsername())
                .setText(R.id.tv_name, item.getName())
                .setText(R.id.tv_no, item.getNo())
                .setText(R.id.tv_dept, item.getDept())
                .setText(R.id.tv_add_date, item.getAddDate())
                .setVisible(R.id.tv_del, !item.getUsername().equals(Const.ADMIN_USERNAME))
                .addOnClickListener(R.id.tv_edit_info)
                .addOnClickListener(R.id.tv_update_pwd)
                .addOnClickListener(R.id.tv_del);
    }
}

